POV-Ray : Newsgroups : povray.general : Array? : Re: Array? Server Time
10 Aug 2024 03:21:02 EDT (-0400)
  Re: Array?  
From: Ken
Date: 10 Mar 2000 13:22:18
Message: <38C93DE2.2E56417B@pacbell.net>
Bill DeWitt wrote:
> 
> "Margus Ramst" <mar### [at] peakeduee> wrote :
> >
> > #declare A=array[100]
> > #declare N=dimension_size(A,1); file://Auto get the number of elements
> > #declare C=0;
> > #while(C<N)
> >   #declare A[C]=1;
> >   #declare C=C+1;
> > #end
> >
> 
>     This is more or less what I was doing, I just wondered if there was
> anything else to know. I hadn't got the dimension_size thing though, Thanks!

 I was messing with this a few months ago trying to sort irregular shaped
shingles on a roof. I resorted to storing and retrieving from an array. It
looks a bit like the example that Margus showed.

#declare Num = 20;
#declare MyArray = array[Num];
#declare i = 0;
  #while (i < num)
     #declare MyArray[i] = i;
     #declare i = i + 1;
  #end

this stores the current value of i into the array at each position (so
MyArray[5] = 5) to get them out, simply do something like the following

#declare i = 0;
#declare Sum = 0;
#while (i < num)
   #declare Sum = Sum + MyArray[i];
   #declare i = i + 1;   
#end



-- 
Ken Tyler -  1300+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.